#include "BlockQueue.hpp"

void* product(void* args)
{
    int data = 1;
    BlockQueue<int>* bq = (BlockQueue<int>*)args;
    while(true)
    {
        sleep(1);
        std::cout << "生产了一个数据：" << data << std::endl;
        bq->Push(data++);
    }
}

void* consum(void* args)
{
    BlockQueue<int>* bq = (BlockQueue<int>*)args;
    while(true)
    {
        //sleep(1);
        int data = bq->Pop();
        std::cout << "消费了一个数据：" << data << std::endl;
    }
}

int main()
{
    BlockQueue<int>* bq = new BlockQueue<int>();

    pthread_t producter = 0;
    pthread_create(&producter, nullptr, product, bq);

    pthread_t consumer = 0;
    pthread_create(&consumer, nullptr, consum, bq);

    pthread_join(producter, nullptr);
    pthread_join(consumer, nullptr);
    return 0;
}